package com.ruoyi.tongyan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tongyan.domain.TProjectProcess;
import com.ruoyi.tongyan.service.ITProjectProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目过程Controller
 *
 * @author ruoyi
 * @date 2025-05-19
 */
@RestController
@RequestMapping("/tongyan/process")
public class TProjectProcessController extends BaseController
{
    @Autowired
    private ITProjectProcessService tProjectProcessService;

    /**
     * 查询项目过程列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProjectProcess tProjectProcess)
    {
        startPage();
        List<TProjectProcess> list = tProjectProcessService.selectTProjectProcessList(tProjectProcess);
        return getDataTable(list);
    }

    /**
     * 导出项目过程列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:export')")
    @Log(title = "项目过程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProjectProcess tProjectProcess)
    {
        List<TProjectProcess> list = tProjectProcessService.selectTProjectProcessList(tProjectProcess);
        ExcelUtil<TProjectProcess> util = new ExcelUtil<TProjectProcess>(TProjectProcess.class);
        util.exportExcel(response, list, "项目过程数据");
    }

    /**
     * 获取项目过程详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:query')")
    @GetMapping(value = "/{processId}")
    public AjaxResult getInfo(@PathVariable("processId") Long processId)
    {
        return success(tProjectProcessService.selectTProjectProcessByProcessId(processId));
    }

    /**
     * 新增项目过程
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:add')")
    @Log(title = "项目过程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProjectProcess tProjectProcess)
    {
        return toAjax(tProjectProcessService.insertTProjectProcess(tProjectProcess));
    }

    /**
     * 修改项目过程
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:edit')")
    @Log(title = "项目过程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProjectProcess tProjectProcess)
    {
        return toAjax(tProjectProcessService.updateTProjectProcess(tProjectProcess));
    }

    /**
     * 删除项目过程
     */
    @PreAuthorize("@ss.hasPermi('tongyan:process:remove')")
    @Log(title = "项目过程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{processIds}")
    public AjaxResult remove(@PathVariable Long[] processIds)
    {
        return toAjax(tProjectProcessService.deleteTProjectProcessByProcessIds(processIds));
    }
}
